#ifndef __SIPSUBSCRIBESESSION_HPP__
#define __SIPSUBSCRIBESESSION_HPP__

#include "SipGDServiceConfigure.hpp"
#include "SipDlgSessionBase.hpp"
#include "SipB2BSession.hpp"

#define SUBSCRIBE_EXPIRES 360

namespace wtsip{

class CSipSubscribeSession;
class CSipSubscription;

class WTGD_SIPSRV_PUBLIC CSipSubscribeHandle: virtual public CSipSessionHandle
{
public:

    virtual bool onSubscribe(SipMessage& msg, CSipSubscribeSession& subs) = 0;

    virtual bool onNotify(SipMessage& msg, CSipSubscribeSession& subs) = 0;

    //virtual bool onSubscribeOK(SipMessage& msg) = 0;

    //virtual bool onNotifyOK(SipMessage& msg) = 0;

    //virtual bool onSubscribeFailed(SipMessage& msg, CSipSessionBase::EFailReason r) = 0;

    //virtual bool onNotifyFailed(SipMessage& msg, CSipSessionBase::EFailReason r) = 0;

};



class WTGD_SIPSRV_PUBLIC CSipSubscribeSession:
    public CSipDlgSessionBase,
    //public CSipB2BSession,
    public CSipDlgHandle
{
public:
    CSipSubscribeSession(CSipGDService& sv, CSipSubscription& dlg);

    virtual ~CSipSubscribeSession();

    resip::Data subscribe(std::string& contents);

    resip::Data unsubscribe(std::string& contents);

    resip::Data notify(std::string& contents);

    virtual bool messageDresser(SipMessage& msg);

    //virtual const resip::Data& getID();

protected:

    /////////////////////////CSipDlgHandle

    virtual bool isFakeTransation(SipMessage& msg, CSipDialogBase& dlg);

    virtual bool onResponse(SipMessage& msg, CSipDialogBase& dlg);

    virtual bool onRequest(SipMessage& msg, CSipDialogBase& dlg);

    virtual bool onTimeout(ApplicationMessage& msg, CSipDialogBase& dlg);

    virtual bool onDestroy(CSipDialogBase& dlg);

    //virtual bool onB2BRequest(SipMessage& request);

    //virtual bool onB2BResponse(const resip::Data& tid, SipMessage& response);

private:

    virtual bool start(std::string& body);

    virtual bool stop();

    bool handleSubscribe(SipMessage& msg);

    bool handleNotify(SipMessage& msg);

    //CSipSubscribeHandle* m_subHandle;

};



}//namespace

#endif


